//
//  TKL_HomeNewPhotos.m
//  TKL_EnPro
//
//  Created by 雅恩三河科技 on 2019/4/27.
//  Copyright © 2019年 MrZhang. All rights reserved.
//

//
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                  \\`.
//        .'//                     |                     \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \\`.
//    .'//.-"                 `-.  |  .-'                 "-.\\`.
//  .'//______.============-..   \ | /   ..-============.______\\`.
//.'______________________________\|/______________________________`.
//
//

#import "TKL_HomeNewPhotos.h"
#import "Head.h"
#import "TKL_ImageDetailVC.h"
@interface TKL_HomeNewPhotos ()<SDCycleScrollViewDelegate>
@property(nonatomic,strong)NSMutableArray* dataSource;
@end

@implementation TKL_HomeNewPhotos
#pragma mark - getter and setter
-(NSMutableArray *)dataSource
{
    if (!_dataSource) {
        _dataSource=[NSMutableArray new];
    }
    return _dataSource;
}
#pragma mark - event
#pragma mark - method
-(void)initilization
{
    self.isGroup = YES;
    @WeakSelf;
    
    self.navigationController.navigationBar.shadowImage = [[UIImage new]rt_darkenWithLevel:0.1f];
    
    self.navigationItem.title =@"最新客片";
    self.extendedLayoutIncludesOpaqueBars = YES;
    self.baseTable.contentInset = UIEdgeInsetsMake([self topShelterHeight], 0, [self bottomShelterHeight], 0);
    self.view.backgroundColor = Main_Color_BG;
    
    [self.view addSubview:self.baseTable];
    [self.baseTable setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [self.baseTable setSeparatorColor:Main_Color_BG];
    [self viewModelBand];
    
    self.baseTable.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [selfp reloadData];
        [selfp.baseTable.mj_header endRefreshing];
    }];
    [selfp reloadData];
}
-(void)viewModelBand
{
    @WeakSelf;
    
    
}
-(void)reloadListData
{
//    BmobQuery   *bquery = [BmobQuery queryWithClassName:@"newslist"];
//    //查找GameScore表的数据
//    [bquery findObjectsInBackgroundWithBlock:^(NSArray *array, NSError *error) {
//        for (BmobObject *obj in array) {
//            //打印playerName
//            NSLog(@"obj.playerName = %@", [obj objectForKey:@"name"]);
//            //打印objectId,createdAt,updatedAt
//            NSLog(@"obj.objectId = %@", [obj objectForKey:@"ishome"]);
//            NSLog(@"obj.createdAt = %@", [obj createdAt]);
//            NSLog(@"obj.updatedAt = %@", [obj updatedAt]);
//
//        }
//        self.dataSource=[[NSMutableArray alloc] initWithArray:array];
//        [self.baseTable reloadData];
//    }];
    
    [self.dataSource addObject:@[@"image60.jpg",@"image62.jpg",@"image65.jpg",@"image67.jpg",@"image69.jpg"]];
    [self.dataSource addObject:@[@"image71.jpg",@"image73.jpg",@"image75.jpg",@"image78.jpg",@"image77.jpg"]];
    [self.dataSource addObject:@[@"image81.jpg",@"image83.jpg",@"image85.jpg",@"image87.jpg",@"image89.jpg"]];
    [self.dataSource addObject:@[@"image91.jpg",@"image93.jpg",@"image95.jpg",@"image96.jpg",@"image98.jpg"]];
    
}
-(void)reloadData
{
    [self reloadListData];
}
-(void)reloadView
{
    
}
#pragma mark - life

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initilization];
}
#pragma mark - delegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    return self.dataSource.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    @WeakSelf;
    
    static NSString* identify=@"ppPhonecell333";
    UITableViewCell* cell=[tableView dequeueReusableCellWithIdentifier:identify];
    if (!cell)
    {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identify];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        cell.backgroundColor=[UIColor whiteColor];
    }
    [cell.contentView removeAllSubviews];
    
    UIImageView* lineIV=[UIImageView new];
    lineIV.width=WFCGFloatX(345);
    lineIV.x=WFCGFloatX(15);
    lineIV.y=WFCGFloatY(15);
    lineIV.backgroundColor=Main_Color_BG;
    [cell.contentView addSubview:lineIV];
    //        [lineIV sd_setImageWithURL:[NSURL URLWithString:[mode objectForKey:@"image"]] placeholderImage:DefaultImage];
    //        lineIV.contentMode=UIViewContentModeScaleAspectFill;
    //        lineIV.layer.masksToBounds=YES;
    lineIV.image=[UIImage imageNamed:[self.dataSource[indexPath.row] objectAtIndex:0]];
    // lineIV.width=lineIV.image.size.width;
    lineIV.height=lineIV.width*(lineIV.image.size.height/lineIV.image.size.width);
    
    UILabel* titleLab=[UILabel new];
    titleLab.x=WFCGFloatX(0);
    titleLab.y=lineIV.bottom;
    titleLab.width=SCREEN_WIDTH;
    titleLab.height=WFCGFloatY(40);
    titleLab.textColor=HEXCOLOR(@"#171717");
    titleLab.font=SYSTEMFONT(15);
    [cell.contentView addSubview:titleLab];
    titleLab.text=[NSString stringWithFormat:@"2019年4月第%ld期",indexPath.row+1];
    titleLab.textAlignment=NSTextAlignmentCenter;
    
    return cell;

}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIImage* image=[UIImage imageNamed:[self.dataSource[indexPath.row] objectAtIndex:0]];
    // lineIV.width=lineIV.image.size.width;
    return WFCGFloatX(345)*(image.size.height/image.size.width)+WFCGFloatY(55);
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView* view=[UIView new];
    view.backgroundColor=[UIColor whiteColor];
    
    return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{

    return 0.0001f;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView* view=[UIView new];
    view.backgroundColor=Main_Color_BG;
    
    return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{

    return 10;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    TKL_ImageDetailVC* vc=[[TKL_ImageDetailVC alloc] init];
    vc.passObj=self.dataSource[indexPath.row];
    vc.type=2;
    [self.navigationController pushViewController:vc animated:YES];
}

@end


/*
 11111111111111111111111111111111111111001111111111111111111111111
 11111111111111111111111111111111111100011111111111111111111111111
 11111111111111111111111111111111100001111111111111111111111111111
 11111111111111111111111111111110000111111111111111111111111111111
 11111111111111111111111111111000000111111111111111111111111111111
 11111111111111111111111111100000011110001100000000000000011111111
 11111111111111111100000000000000000000000000000000011111111111111
 11111111111111110111000000000000000000000000000011111111111111111
 11111111111111111111111000000000000000000000000000000000111111111
 11111111111111111110000000000000000000000000000000111111111111111
 11111111111111111100011100000000000000000000000000000111111111111
 11111111111111100000110000000000011000000000000000000011111111111
 11111111111111000000000000000100111100000000000001100000111111111
 11111111110000000000000000001110111110000000000000111000011111111
 11111111000000000000000000011111111100000000000000011110001111111
 11111110000000011111111111111111111100000000000000001111100111111
 11111111000001111111111111111111110000000000000000001111111111111
 11111111110111111111111111111100000000000000000000000111111111111
 11111111111111110000000000000000000000000000000000000111111111111
 11111111111111111100000000000000000000000000001100000111111111111
 11111111111111000000000000000000000000000000111100000111111111111
 11111111111000000000000000000000000000000001111110000111111111111
 11111111100000000000000000000000000000001111111110000111111111111
 11111110000000000000000000000000000000111111111110000111111111111
 11111100000000000000000001110000001111111111111110001111111111111
 11111000000000000000011111111111111111111111111110011111111111111
 11110000000000000001111111111111111100111111111111111111111111111
 11100000000000000011111111111111111111100001111111111111111111111
 11100000000001000111111111111111111111111000001111111111111111111
 11000000000001100111111111111111111111111110000000111111111111111
 11000000000000111011111111111100011111000011100000001111111111111
 11000000000000011111111111111111000111110000000000000011111111111
 11000000000000000011111111111111000000000000000000000000111111111
 11001000000000000000001111111110000000000000000000000000001111111
 11100110000000000001111111110000000000000000111000000000000111111
 11110110000000000000000000000000000000000111111111110000000011111
 11111110000000000000000000000000000000001111111111111100000001111
 11111110000010000000000000000001100000000111011111111110000001111
 11111111000111110000000000000111110000000000111111111110110000111
 11111110001111111100010000000001111100000111111111111111110000111
 11111110001111111111111110000000111111100000000111111111111000111
 11111111001111111111111111111000000111111111111111111111111100011
 11111111101111111111111111111110000111111111111111111111111001111
 11111111111111111111111111111110001111111111111111111111100111111
 11111111111111111111111111111111001111111111111111111111001111111
 11111111111111111111111111111111100111111111111111111111111111111
 11111111111111111111111111111111110111111111111111111111111111111
 
 
 */
